var n = require("../../../@babel/runtime/helpers/defineProperty"), i = getApp();

Page({
    data: {
        img_url_1: "",
        img_url_2: "",
        img_url_3: "",
        agreement: !1,
        th_pass: "",
        th_name: "",
        order_id: 0,
        examine_success: !1,
        configInfo: {},
        plugin: "picking-card"
    },
    onLoad: function(n) {
        n.orderid && 0 != n.orderid && null != n.orderid && (this.data.order_id = n.orderid), 
        n.plugin && "one" == n.plugin && (this.data.plugin = "picking-card-one", wx.setNavigationBarTitle({
            title: "保证金退款"
        })), this.getConfigInfo(), this.getExamineInfo();
    },
    getExamineInfo: function() {
        var n = this, e = "plugin.picking-card.frontend.pickingCard.checkRefundStatus";
        "picking-card-one" == this.data.plugin && (e = "plugin.picking-card-one.frontend.pickingCard.checkRefundStatus");
        var t = i.getNetAddresss(e);
        i._getNetWork({
            url: t,
            data: {
                order_id: this.data.order_id
            },
            success: function(i) {
                var e = i.data;
                1 == e.result && (console.log(e), 0 === e.data && n.setData({
                    examine_success: !0
                }));
            }
        });
    },
    onReady: function() {},
    getConfigInfo: function() {
        var n = this, e = "plugin.picking-card.frontend.pickingCard.getConfig";
        "picking-card-one" == this.data.plugin && (e = "plugin.picking-card-one.frontend.pickingCard.getConfig");
        var t = i.getNetAddresss(e);
        i._getNetWork({
            url: t,
            success: function(i) {
                var e = i.data;
                1 == e.result && (console.log(e), n.setData({
                    configInfo: e.data
                }));
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    setExplainFlag: function() {
        this.setData({
            explainFlag: !this.data.explainFlag
        });
    },
    onUnload: function() {},
    send: function() {
        var n = this, e = this.data, t = e.th_pass, a = e.th_name, o = e.img_url_1, r = e.img_url_2, s = e.img_url_3, d = e.agreement, c = e.order_id;
        if (0 == c) return this.tips("参数错误");
        if ("" == a) return this.tips("原订单收件人姓名不能为空");
        if ("" == t) return this.tips("原订单收件人手机号不能为空");
        if ("" == o || "" == r || "" == s) return this.tips("凭证必须为三张");
        if (0 == d) return this.tips("请勾选退款说明");
        var g = "plugin.picking-card.frontend.pickingCard.postRefund";
        "picking-card-one" == this.data.plugin && (g = "plugin.picking-card-one.frontend.pickingCard.postRefund");
        var u = i.getNetAddresss(g);
        i._postNetWork({
            url: u,
            data: {
                order_id: c,
                realname: a,
                mobile: t,
                password: this.data.th_pass,
                images: o + "," + r + "," + s
            },
            success: function(i) {
                var e = i.data;
                if (1 != e.result) return n.tips(e.msg);
                n.setData({
                    examine_success: !0
                }), console.log(e);
            }
        });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onChange: function(n) {
        this.setData({
            agreement: n.detail
        });
    },
    onRead: function(e) {
        var t = e.currentTarget.dataset.index;
        console.log(t);
        var a = this, o = wx.getStorageSync("wx_token"), r = wx.getStorageSync("session"), s = "plugin.picking-card.frontend.pickingCard.upload";
        "picking-card-one" == this.data.plugin && (s = "plugin.picking-card-one.frontend.pickingCard.upload");
        var d = i.getNetAddresss(s);
        d += "&3rd_session=" + r, wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(i) {
                var e = i.tempFilePaths;
                wx.showLoading({
                    title: "上传中"
                }), wx.uploadFile({
                    url: d,
                    filePath: e[0],
                    name: "file",
                    header: {
                        "Content-Type": "application/json",
                        Accept: "application/json",
                        Cookie: "PHPSESSID=" + o
                    },
                    success: function(i) {
                        wx.hideLoading();
                        var e = JSON.parse(i.data);
                        if (console.log(e), 1 == e.result) {
                            var o = "img_url_" + t;
                            a.setData(n({}, o, e.data.img));
                        } else wx.showToast({
                            icon: "none",
                            title: e.msg,
                            duration: 1500
                        });
                    }
                });
            }
        });
    },
    tips: function(n) {
        return wx.showToast({
            icon: "none",
            title: n
        }), !1;
    },
    onShareAppMessage: function() {}
});